package cn.com.controller;

import cn.com.beans.MajorInfo;
import cn.com.beans.MajorType;
import cn.com.beans.ProfessionInfo;
import cn.com.service.MajorInfoService;
import cn.com.service.MajorTypeService;
import cn.com.service.ProfessionInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/major")
public class MajorController {

    @Resource
    private MajorInfoService majorInfoService;
    @Resource
    private MajorTypeService majorTypeService;
    @Resource
    ProfessionInfoService professionInfoService;

    @GetMapping
    public String majorlist(Model model) {
        List<MajorType> majorTypeList = majorTypeService.findAll(null);
        List<MajorInfo> majorInfoList = majorInfoService.findAll(null);
        model.addAttribute("typeList",majorTypeList);
        model.addAttribute("infoList",majorInfoList);
        return "query/majorList";
    }
    @GetMapping("find")
    public String find(Integer id,Model model) {

        List<ProfessionInfo> professionInfoList = professionInfoService.findByMaid(id);
        model.addAttribute("professionList" ,professionInfoList);
        MajorInfo majorInfo = majorInfoService.selectByPrimaryKey(id);
        model.addAttribute("major", majorInfo);
        return "query/majorInfo";
    }
}
